﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>公司介绍信息</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="../../../js/jquery/boot.js" type="text/javascript"></script>
<script src="../../../js/kindeditor/kindeditor-min.js"></script>
<script src="../../../js/kindeditor/lang/zh_CN.js"></script>
<style type="text/css">
html,body {
	font-size: 12px;
	padding: 0;
	margin: 0;
	border: 0;
	height: 100%;
	overflow: hidden;
}
</style>
</head>
<body>

<form id="form1" method="post">
	<input name="id" class="mini-hidden" />
	<input name="content" class="mini-hidden" />
	<div style="padding-left: 11px; padding-bottom: 5px;">
	<table style="table-layout: fixed;">
		<tr>
			<td style="width: 70px;">公司介绍：</td>
			<td style="width: 700px;"><textarea name="kindeditor" style="width:600px;height:300px;visibility:hidden;"></textarea></td>
		</tr>
	</table>
	</div>
	<div style="text-align: center; padding: 10px;">
		<a class="mini-button" onclick="onOk" style="width: 60px; margin-right: 20px;">确定</a> 
		<a class="mini-button" onclick="onCancel" style="width: 60px;">取消</a>
	</div>
</form>
<script type="text/javascript">
        mini.parse();

        var form = new mini.Form("form1");
        
        var editor;
		KindEditor.ready(function(K) {
			editor = K.create('textarea[name="kindeditor"]', {
				//allowFileManager : true
				resizeType : 1,
				allowPreviewEmoticons : false,
				allowImageUpload : false,
				items : [
					'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
					'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
					'insertunorderedlist', '|', 'emoticons', 'image', 'link']
			});
		});

        function SaveData() {
            var o = form.getData();            

            form.validate();
            if (form.isValid() == false) return;
            
            o.content = editor.html();
            var json = mini.encode(o);
            $.ajax({
                url: "../../../companyInfo/create.jsps",
                data: { companyInfo : json },
                cache: false,
                success: function (text) {
                	if (text == "" || typeof(text) == 'object') {
                    	CloseWindow("save");
                	} else {
                		var error = mini.decode(text);
                		mini.alert(error.error);
                   	}
                },
                error: function (jqXHR, textStatus, errorThrown) {
                	mini.alert(jqXHR.responseText);
                }
            });
        }

        function UpdateData() {
            var o = form.getData();            

            form.validate();
            if (form.isValid() == false) return;

            o.content = editor.html();
            var json = mini.encode(o);
            $.ajax({
                url: "../../../companyInfo/update.jsps",
                data: { companyInfo : json },
                cache: false,
                success: function (text) {
                	if (text == "" || typeof(text) == 'object') {
                    	CloseWindow("save");
                	} else {
                		var error = mini.decode(text);
                		mini.alert(error.error);
                   	}
                },
                error: function (jqXHR, textStatus, errorThrown) {
                	mini.alert(jqXHR.responseText);
                }
            });
        }

        ////////////////////
        //标准方法接口定义
        var isEdit = false;
        function SetData(data) {
            if (data.action == "edit") {
                isEdit = true;
                //跨页面传递的数据对象，克隆后才可以安全使用
                data = mini.clone(data);
                $.ajax({
                    url: "../../../companyInfo/read.jsps",
                    data: { id: data.id },
                    cache: false,
                    success: function (text) {
                        var o = mini.decode(text);
                        form.setData(o);
                        form.setChanged(false);
                        editor.html(o.content);
                    }
                });
            }
        }

        function GetData() {
            var o = form.getData();
            return o;
        }
        function CloseWindow(action) {            
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();            
        }
        function onOk(e) {
            if (!isEdit) {
            	SaveData();
            } else {
				UpdateData();
            }
        }
        function onCancel(e) {
            CloseWindow("cancel");
        }
    </script>
</body>
</html>
